package swing;

import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;

public class SwingToolBar extends JToolBar{
	
	private static SwingMenuActionList action = null;
	private String imgPath = "/imagestoolbar/";
	private String imgExt = ".png";
	
	public SwingToolBar() {
		action = new SwingMenuActionList();
		setFloatable(false);
		addToolBarButton(); 	//툴바에 버튼 추가
	}
	
	private void addToolBarButton(){
		add(makeToolBarButton("new_4","새로하기"));
		add(makeToolBarButton("close","끄기"));
		add(makeToolBarButton("exit","종료하기"));

}
	private JButton makeToolBarButton(
		String img,  String tooltip){
		 JButton btn = new JButton();
		 btn.setFocusable(false);
		 btn.addActionListener(action);
		 btn.setActionCommand(img);
		 btn.setToolTipText(tooltip);
		 
		 URL iconPath = getClass().getResource(imgPath + img + imgExt);
		 btn.setIcon(new ImageIcon(iconPath));
		 return btn;
		}
	}